package com.army.stock.service.impl;

import com.army.stock.dao.ArmyInstorageOrderDao;
import com.army.stock.domain.ArmyInstorageOrder;
import com.army.stock.service.ArmyInstorageOrderService;
import com.javalife.common.domain.page.PaginatedArrayList;

import java.util.List;
import java.util.Map;

/**
 * Created by zhangyong on 15/3/7.
 */
public class ArmyInstorageOrderServiceImpl implements ArmyInstorageOrderService {

    private ArmyInstorageOrderDao armyInstorageOrderDao;

    public void setArmyInstorageOrderDao(ArmyInstorageOrderDao armyInstorageOrderDao) {
        this.armyInstorageOrderDao = armyInstorageOrderDao;
    }

    public PaginatedArrayList getInstorageOrderPageInfo(int currentPage, int pageSize, Map<String, Object> map) {
        int startNum = (currentPage - 1) * pageSize;
        map.put("start", startNum);
        map.put("pageSize", pageSize);
        Integer count = armyInstorageOrderDao.getCountInstorageOrder(map);
        List<ArmyInstorageOrder> instorageOrders = armyInstorageOrderDao.gettInstorageOrderList(map);
        PaginatedArrayList<ArmyInstorageOrder> paginatedArrayList = new PaginatedArrayList<ArmyInstorageOrder>(currentPage, pageSize);
        paginatedArrayList.setTotalItem(count);
        paginatedArrayList.addAll(instorageOrders);
        return paginatedArrayList;
    }

}
